package com.yuyue.dronesystem.entities;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.yuyue.dronesystem.enums.UserAuthority;

/**
 * UserInfo
 */
@Entity
@Table(name = "user_information")
public class UserInfo {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "user_id")
    private Long userId;
    @Column(name = "nick_name")
    private String nickName;
    @Column(name = "authority")
    @Enumerated(value = EnumType.STRING)
    private UserAuthority authority;
    @Column(name = "create_time")
    private Long createTime;
    @Column(name = "login_time")
    private Long loginTime;
    @Column(name = "logout_time")
    private Long logoutTime;
    @Column(name = "status")
    private Boolean status;
    @Column(name = "remark")
    private String remark;

    @OneToMany(mappedBy = "userInfo", cascade = CascadeType.ALL)
    private Set<UserLogin> userLogins = new HashSet<>();

    public UserInfo() {
    }

    public UserInfo(Long userId, String nickName, UserAuthority authority, Long createTime, Long loginTime, Long logoutTime, Boolean status, String remark) {
        this.userId = userId;
        this.nickName = nickName;
        this.authority = authority;
        this.createTime = createTime;
        this.loginTime = loginTime;
        this.logoutTime = logoutTime;
        this.status = status;
        this.remark = remark;
    }

    public Long getUserId() {
        return this.userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getNickName() {
        return this.nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public UserAuthority getAuthority() {
        return this.authority;
    }

    public void setAuthority(UserAuthority authority) {
        this.authority = authority;
    }

    public Long getCreateTime() {
        return this.createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getLoginTime() {
        return this.loginTime;
    }

    public void setLoginTime(Long loginTime) {
        this.loginTime = loginTime;
    }

    public Long getLogoutTime() {
        return this.logoutTime;
    }

    public void setLogoutTime(Long logoutTime) {
        this.logoutTime = logoutTime;
    }

    public Boolean isStatus() {
        return this.status;
    }

    public Boolean getStatus() {
        return this.status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public String getRemark() {
        return this.remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    /**
     * @return the userLogins
     */
    public Set<UserLogin> getUserLogins() {
        return userLogins;
    }

    /**
     * @param userLogins the userLogins to set
     */
    public void setUserLogins(Set<UserLogin> userLogins) {
        this.userLogins = userLogins;
    }

    public UserInfo userId(Long userId) {
        this.userId = userId;
        return this;
    }

    public UserInfo nickName(String nickName) {
        this.nickName = nickName;
        return this;
    }

    public UserInfo authority(UserAuthority authority) {
        this.authority = authority;
        return this;
    }

    public UserInfo createTime(Long createTime) {
        this.createTime = createTime;
        return this;
    }

    public UserInfo loginTime(Long loginTime) {
        this.loginTime = loginTime;
        return this;
    }

    public UserInfo logoutTime(Long logoutTime) {
        this.logoutTime = logoutTime;
        return this;
    }

    public UserInfo status(Boolean status) {
        this.status = status;
        return this;
    }

    public UserInfo remark(String remark) {
        this.remark = remark;
        return this;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this)
            return true;
        if (!(o instanceof UserInfo)) {
            return false;
        }
        UserInfo userInfo = (UserInfo) o;
        return Objects.equals(userId, userInfo.userId) && Objects.equals(nickName, userInfo.nickName) && Objects.equals(authority, userInfo.authority) && Objects.equals(createTime, userInfo.createTime) && Objects.equals(loginTime, userInfo.loginTime) && Objects.equals(logoutTime, userInfo.logoutTime) && Objects.equals(status, userInfo.status) && Objects.equals(remark, userInfo.remark);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId, nickName, authority, createTime, loginTime, logoutTime, status, remark);
    }

    @Override
    public String toString() {
        return "{" +
            " userId='" + getUserId() + "'" +
            ", nickName='" + getNickName() + "'" +
            ", authority='" + getAuthority() + "'" +
            ", createTime='" + getCreateTime() + "'" +
            ", loginTime='" + getLoginTime() + "'" +
            ", logoutTime='" + getLogoutTime() + "'" +
            ", status='" + isStatus() + "'" +
            ", remark='" + getRemark() + "'" +
            "}";
    }
}